//	--------------------------------------------------------------------
//	Copyright(C) 2006,2007 Zhao Yukun. All rights reserved.
//	This file is a part of the Xeres system.
//	Xeres 2007
//	Contact : xeres.engine@gmail.com
//	$(reservedInfo)
//	$(reservedDeclaration)
//	--------------------------------------------------------------------
///	@file	<XPopup.cpp>
///	@path	~/src/gui/xgui/
///	@date	2008/10/01
///	@desc	.

#define _FULLAPI
#include "config/config.h"

#include "gui/composite/composition.h"
#include "gui/xgui/XPopup.h"
#include "gui/xgui/XDesktop.h"

namespace xeres {

	IMPL_IOBJECT_CLASS_DYNAMIC( XPopup );

	// XPopup
	XPopup::XPopup( void )
	{

	}
	// XPopup
	XPopup::XPopup( const Rect<int>& placement )
	{

	}
	// XPopup
	XPopup::XPopup( const Pair<int>& size )
	{

	}
	// ~XPopup
	XPopup::~XPopup( void )
	{

	}
	// SetBackground
	void XPopup::SetBackground( RefWeak<IBitmap> bmp )
	{
		m_background = bmp;
		UpdateControl();
	}
	// OnFocusIn
	void XPopup::OnFocusIn( Updater& updater , RefWeak<IGuiComp> last )
	{
		__super::OnFocusIn( updater , last );
	}
	// OnFocusOut
	void XPopup::OnFocusOut( Updater& updater , RefWeak<IGuiComp> next )
	{
		__super::OnFocusOut( updater , next );
		if( next != m_subPopup )
		{
			RefWeak<XDesktop> parent = GetParent();
			parent->ShowWindow( this , false , true );
		}
	}
	// OnDrawBackground
	void XPopup::OnDrawBackground( Composition& composition )
	{
		if( m_background.IsValid() )
		{
			composition.painter().StcBitmap( m_background , Pair<int>(0,0) , GetBound() , 255 , 0 , 8 , 8 );
		}
		else
		{
			__super::OnDrawBackground( composition );
		}
	}
	
} // namespace xeres
